﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace BackGroundTesting
{
    class TiledBG: Sprite
    {
        //ContentManager Content;


        //tiles separados
        animation tile1;
        animation tile2;
        animation tile3;
        animation tile4;

        int mapValue;
        
        //enum de mapas porque tem um numero limitado de tiles
        enum Tile {TILE1, TILE2, TILE3, TILE4 };

        Tile tile;
        
        public TiledBG(Texture2D texture, Vector2 position, Array map,Vector2 mapPosition ):base(texture)
        {
            mapValue = (int)map.GetValue((int)mapPosition.X, (int)mapPosition.Y);

            if (mapValue == 1)
                tile = Tile.TILE1;

            else if (mapValue == 2)
                tile = Tile.TILE2;

            else if (mapValue == 3)
                tile = Tile.TILE3;

            else
                tile = Tile.TILE4;

            switch (tile)
            {
                case Tile.TILE1:
                    tile1 = new animation();
                    tile1.frame.X = 0;
                    tile1.frame.Y = 0;
                    tile1.frame.Width = 16;
                    tile1.frame.Height = 16;
                    tile1.frames = 1;
                    tile1.current_frame = 1;
                    tile1.fps = 1;
                    break;

                case Tile.TILE2:
                    tile2 = new animation();
                    tile2.frame.X = 0;
                    tile2.frame.Y = 0;
                    tile2.frame.Width = 16;
                    tile2.frame.Height = 16;
                    tile2.frames = 1;
                    tile2.current_frame = 2;
                    tile2.fps = 1;
                    break;

                case Tile.TILE3:
                    tile3 = new animation();
                    tile3.frame.X = 0;
                    tile3.frame.Y = 0;
                    tile3.frame.Width = 16;
                    tile3.frame.Height = 16;
                    tile3.frames = 1;
                    tile3.current_frame = 3;
                    tile3.fps = 1;
                    break;

                case Tile.TILE4:
                    tile4 = new animation();
                    tile4.frame.X = 0;
                    tile4.frame.Y = 0;
                    tile4.frame.Width = 16;
                    tile4.frame.Height = 16;
                    tile4.frames = 1;
                    tile4.current_frame = 4;
                    tile4.fps = 1;
                    break;
            }

        }
        public override void Update(GameTime gameTime)
        {

        }

        
    }
}
